cmake_minimum_required(VERSION 3.8)
project(rm_detector)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(image_transport REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(OpenCV REQUIRED)

add_executable(Publisher_node 
  src/Publisher_node.cpp
  src/ArmorDetector.cpp
)
add_executable(Subscriber_node 
  src/Subscriber_node.cpp
)

target_link_libraries(Publisher_node
  ${OpenCV_LIBS})
target_link_libraries(Subscriber_node
  ${OpenCV_LIBS})

target_include_directories(Publisher_node PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>)
target_include_directories(Subscriber_node PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>)

target_compile_features(Publisher_node PUBLIC c_std_99 cxx_std_17)  # Require C99 and C++17
ament_target_dependencies(
  Publisher_node
  "rclcpp"
  "image_transport"
  "cv_bridge"
  "OpenCV"
)

target_compile_features(Subscriber_node PUBLIC c_std_99 cxx_std_17)  # Require C99 and C++17
ament_target_dependencies(
  Subscriber_node
  "rclcpp"
  "image_transport"
  "cv_bridge"
  "OpenCV"
)

install(TARGETS 
  Publisher_node
  DESTINATION lib/${PROJECT_NAME})
install(TARGETS 
  Subscriber_node
  DESTINATION lib/${PROJECT_NAME})
install(
  DIRECTORY launch
  DESTINATION share/${PROJECT_NAME}
)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
